using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class MasterPage : System.Web.UI.MasterPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session[CE.Global.General.UserEmail] == null)
        {
            AdminMenu1.Visible = false;
        }
        else
        {
            AdminMenu1.Visible = true;
        }

        string _strCXLive = CE.Configuration.MyConfigurationManager.GetAppSettingValue("TH.IsCXLive");
        if (_strCXLive == "0")
        {
            if (Session[CE.Global.General.Guest] == null)
            {
                Response.Redirect("~/Default.aspx");
            }
            else if (Session[CE.Global.General.Guest].ToString() == "Provider")
            {
                if (Session[CE.Global.General.UserId] == null)
                {
                    Response.Redirect("~/Provider/ProviderSecureLogin.aspx");
                }
                else if (Session[CE.Global.General.UserTypeId] != null)
                {
                    if (Convert.ToInt32(Session[CE.Global.General.UserTypeId].ToString()) == Convert.ToInt32(CE.Global.CEUserType.Provider))
                    {
                        Response.Redirect("~/Provider/ProviderHome.aspx");
                    }
                    else
                    {
                        Response.Redirect("~/Car-Insurance/Profile.aspx");
                    }
                }
                else
                {
                    Response.Redirect("~/Provider/ProviderSecureLogin.aspx");
                }
            }
        }

        if (Request.UserAgent.IndexOf("AppleWebKit") > 0)
        {
            Request.Browser.Adapters.Clear();
        }
    }
}
